home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / List Manager for Lightspeed C / lmgrtst.c < prev   
Encoding:
C/C++ Source or Header  |  1986-05-25  |  1.6 KB  |  80 lines  |  [TEXT/KAHL]

  1. /*    List Manager test
  2.     Walter R. Smith, 21 April 1986
  3.     
  4.     This application is not actually linkable without my library
  5.     UILib, but it does illustrate the most-used List Manager calls.
  6.     
  7.     This puts a vertically-scrollable list of text in the window.
  8.     Double-clicking on an item deletes it from the list.
  9.  */
  10.  
  11. #include <WindowMgr.h>
  12. #include <EventMgr.h>
  13. #include <UILib.h>
  14. #include <ListMgr.h>
  15.  
  16. Handle mymenus[1];
  17. DoMenu() {}
  18. DoKey() {}
  19.  
  20. WindowRecord mywin;
  21. ListHandle mylist;
  22.  
  23. myupdate(win)
  24. WindowPeek win;
  25. {
  26.     Rect box;
  27.     
  28.     box = (*mylist)->rView;
  29.     InsetRect(&box, -1, -1);
  30.     FrameRect(&box);
  31.     LUpdate(thePort->visRgn, mylist);
  32. }
  33.  
  34. myclose()
  35. {
  36.     ExitToShell();
  37. }
  38.  
  39. myclick(win, where)
  40. WindowPeek win;
  41. Point where;
  42. {
  43.     long w;
  44.     
  45.     if (LClick(where, 0, mylist)) {
  46.         w = LLastClick(mylist);
  47.         LDelRow(1, (int) (w>>16), mylist);
  48.         InvalRect(&(*mylist)->rView);
  49.     }
  50. }
  51.  
  52. main()
  53. {
  54.     Rect bounds, lbounds, databounds;
  55.     Point csize, cell;
  56.     int i;
  57.     static char *msgs[] = { "\pOranges", "\pLemons", "\pStrawberries",
  58.         "\pApples", "\pBananas", "\pT. S. Eliot", "\pKiwi", "\pPineapples",
  59.         "\pCoconut", "\pWatermelon" };
  60.     
  61.     InitBS();
  62.     
  63.     SetRect(&lbounds, 40, 40, 120, 40+5*15);
  64.     SetRect(&bounds, 40, 40, 180, 120+5*15);
  65.     BSNewWindow(&mywin, &bounds, "\pList Manager Test", 1, 0, 1,
  66.         0L, myupdate, myclose, myclick, 0);
  67.     lbounds.right -= 15;
  68.     SetRect(&databounds, 0, 0, 1, 0);
  69.     csize.h = 150;
  70.     csize.v = 15;
  71.     mylist = LNew(&lbounds, &databounds, csize, 0, &mywin,
  72.         TRUE, TRUE, TRUE, TRUE);
  73.     LAddRow(10, 0, mylist);
  74.     cell.h = 0;
  75.     for (cell.v = 0; cell.v < 10; cell.v++)
  76.         LSetCell(msgs[cell.v]+1, (int) *msgs[cell.v], cell, mylist);
  77.     
  78.     while (1) BSOneEvent();
  79. }
  80.